package com.nic.view.widget;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;

import com.nic.view.R;
import com.nic.view.util.glide.GlideUtil;


/**
 * Created by Administrator on 2018/6/7.
 */

public class LookLargePhotoDialog extends Dialog {
    private Context mContext;


    public LookLargePhotoDialog(@NonNull Context context) {
        super(context, R.style.CommentStyle);
        init(context);
    }

    private void init(Context context) {
        this.mContext = context;

        setContentView(R.layout.dialog_large);
//        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        getWindow().setWindowAnimations(R.style.dialogWindowAnim);
        imageView = (ZoomImageView) findViewById(R.id.iv_large);
        ImageView imageViewD = (ImageView) findViewById(R.id.iv_delete_photo);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                GlideUtil.getInstance().clear(imageView);
                dismiss();
            }
        });

    }

    @Override
    public void show() {
        super.show();
        /**
         * 设置宽度全屏，要设置在show的后面
         */
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.gravity = Gravity.BOTTOM;
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().getDecorView().setPadding(0, 0, 0, 0);
        getWindow().setAttributes(layoutParams);
    }

    private ZoomImageView imageView;

    public ZoomImageView getImageView() {
        return imageView;
    }
}
